package com.twu.biblioteca.view;

import com.twu.biblioteca.controller.UserController;
import java.util.Dictionary;
import java.util.Enumeration;

/**
 * Created with IntelliJ IDEA.
 * User: ema93sh
 * Date: 8/9/13
 * Time: 5:48 PM
 */
public class MembershipView implements MenuItem {
    private UserController userController;
    public MembershipView(UserController userController) {
        this.userController = userController;
    }

    @Override
    public String displayTitle() {
        return "Membership Details";
    }

    @Override
    public void doWork() {
        if (userController.isUserLoggedIn())
        {
            Dictionary<String, String> userDetails = userController.getCurrentUser().getUserDetails();
            System.out.println("User Details:");
            Enumeration detail = userDetails.keys();
            while (detail.hasMoreElements())
            {
                String property = (String) detail.nextElement();
                System.out.println(property + ":" + userDetails.get(property));
            }

        }
        else {
            System.out.println("Please talk to a Librarian. Thank you.");
        }
    }
}
